#pragma once
#include"RBTree.h"

namespace bit
{
	template<class K>
	class set
	{
		struct KeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};

		typedef RBTree<K, K, KeyOfT> Tree;
	public:
		typedef typename RBTree<K, K, KeyOfT>::iterator iterator;

		pair<iterator,bool> insert(const K& key)
		{
			return _root.Insert(key);
		}

		iterator begin()
		{
			return _root.Begin();
		}

		iterator end()
		{
			return _root.End();
		}

		bool find(const K& key)
		{
			return _root.Find(key);
		}


	private:
		Tree _root;
	};

	void test_set()
	{
		set<int> st;

		int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14,8, 3, 1, 10, 6, 4, 7, 14, 13 };
		for (auto e : a)
		{
			st.insert(e);
		}

		for (auto e : st)
		{
			cout << e << " ";
		}
		cout << endl;

		cout << st.find(5) << endl;
	}
}